package cn.bonoon.kernel.io;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.MappedSuperclass;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import cn.bonoon.kernel.support.entities.AbstractPersistable;

/**
 * 所有文件上传的，都应该使用这个实体的父类
 * @author jackson
 *
 */
@MappedSuperclass
public abstract class AbstractStoragePersistable extends AbstractPersistable implements StoragePersistable{

	private static final long serialVersionUID = -1616689284636241835L;
	
	@Column(name = "C_PATH", length = 1024)
	private String path;

	@Column(name = "C_FILENAME", length = 200)
	private String filename;

	@Column(name = "C_SIZE")
	private Long size;
	
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "C_CREATEAT")
	private Date createAt;

	@Column(name = "C_CHECKEDCOUNT")
	private Integer checkedCount;
	
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "C_CHECKEDAT")
	private Date checkedAt;
	
	@Column(name = "C_DELETED")
	private boolean deleted;

	//文件的后缀名  去掉.号
	@Column(name = "C_POSTFIX", length = 255)
	private String postfix;
	
	@Override
	public String toSize() {
		return FileSize.valueOf(size).toString();
	}
	
	@Override
	public boolean hasFile() {
		return null != size && size > 0;
	}
	
	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	public String getFilename() {
		return filename;
	}

	public void setFilename(String filename) {
		this.filename = filename;
	}

	public Long getSize() {
		return size;
	}

	public void setSize(Long size) {
		this.size = size;
	}

	public Date getCreateAt() {
		return createAt;
	}

	public void setCreateAt(Date createAt) {
		this.createAt = createAt;
	}

//	public int getCheckedCount() {
//		return checkedCount;
//	}
//
//	public void setCheckedCount(int checkedCount) {
//		this.checkedCount = checkedCount;
//	}

	public Date getCheckedAt() {
		return checkedAt;
	}

	public void setCheckedAt(Date checkedAt) {
		this.checkedAt = checkedAt;
	}

	public boolean isDeleted() {
		return deleted;
	}

	public void setDeleted(boolean deleted) {
		this.deleted = deleted;
	}

	public String getPostfix() {
		return postfix;
	}

	public void setPostfix(String postfix) {
		this.postfix = postfix;
	}

	public Integer getCheckedCount() {
		return checkedCount;
	}

	public void setCheckedCount(Integer checkedCount) {
		this.checkedCount = checkedCount;
	}

	
	
	
}
